package cn.tedu.search.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

@Data
@Accessors(chain = true)    //支持链式set赋值
@AllArgsConstructor         //
@NoArgsConstructor

//  @Document注解标记当前类是ES框架对应的实体类
//  属性indexName指定ES对应的索引名称，运行时，如果这个索引不存在，SpringData会自动创建它
@Document(indexName = "items")
public class Item implements Serializable {
   //  SpringData通过@Id标记当前实体类的主键属性
   @Id
   private Long id;
    @Field(type = FieldType.Text,
            analyzer = "ik_max_word",
            searchAnalyzer = "ik_max_word")
   private String title;
   @Field(type = FieldType.Keyword)
   private String category;
   @Field(type = FieldType.Keyword)
   private String brand;
   @Field(type = FieldType.Double)
   private Double price;
   @Field(type = FieldType.Keyword,index = false)
   private String imgPath;
}
